/**
  ******************************************************************************
  * @file    DSTIN_CFG.h
  * @author  Feirui_Joe
  * @version V0.1
  * @date    07/26/2010
  * @brief   Outputs Driver
  ******************************************************************************
  * @copy
  *
  * <h2><center>&copy; COPYRIGHT 2010 Feirui</center></h2>
  */ 



/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef  __DSTIN_CFG_H__
#define  __DSTIN_CFG_H__


#ifdef __cplusplus
 extern "C" {
#endif


/**
  * @brief  INCLUDE FILES.
  */


/**
  * @brief GLOBALS RAM definition
  */
#ifdef   DSTIN_CFG_GLOBALS
#define  DSTIN_CFG_EXT
#else
#define  DSTIN_CFG_EXT  extern
#endif



/***********************************************************/
/****************** Digital Input define   *****************/
/***********************************************************/
/**
  * @brief   Inputs with external interrupt
  
  * @param2  DST IN1------------------PD8  (I)
  * @param3  DST IN2------------------PD9  (I)
  * @param4  DST IN3------------------PD10 (I)
  * @param5  DST IN4------------------PD11 (I)
  * @param6  DST IN5------------------PD12 (I)
  * @param7  DST IN6------------------PD13 (I)
  * @param8  DST IN7------------------PD14 (I)
  * @param9  DST IN8------------------PE5  (I)
  * @param1  EM STOP------------------PD15 (I)
  */

#define RCCPeriph_InputIN1              RCC_APB2Periph_GPIOD
#define GPIOModeI_InputIN1              GPIO_Mode_IPU
#define GPIOSpeed_InputIN1              GPIO_Speed_2MHz
#define GPIOxPort_InputIN1              GPIOD
#define GPIOxBitx_InputIN1              GPIO_Pin_8

#define RCCPeriph_InputIN2              RCC_APB2Periph_GPIOD
#define GPIOModeI_InputIN2              GPIO_Mode_IPU
#define GPIOSpeed_InputIN2              GPIO_Speed_2MHz
#define GPIOxPort_InputIN2              GPIOD
#define GPIOxBitx_InputIN2              GPIO_Pin_9

#define RCCPeriph_InputIN3              RCC_APB2Periph_GPIOD 
#define GPIOModeI_InputIN3              GPIO_Mode_IPU
#define GPIOSpeed_InputIN3              GPIO_Speed_2MHz     
#define GPIOxPort_InputIN3              GPIOD                
#define GPIOxBitx_InputIN3              GPIO_Pin_10    

#define RCCPeriph_InputIN4              RCC_APB2Periph_GPIOD 
#define GPIOModeI_InputIN4              GPIO_Mode_IPU
#define GPIOSpeed_InputIN4              GPIO_Speed_2MHz     
#define GPIOxPort_InputIN4              GPIOD                
#define GPIOxBitx_InputIN4              GPIO_Pin_11  

#define RCCPeriph_InputIN5              RCC_APB2Periph_GPIOD 
#define GPIOModeI_InputIN5              GPIO_Mode_IPU
#define GPIOSpeed_InputIN5              GPIO_Speed_2MHz     
#define GPIOxPort_InputIN5              GPIOD                
#define GPIOxBitx_InputIN5              GPIO_Pin_12    

#define RCCPeriph_InputIN6              RCC_APB2Periph_GPIOD 
#define GPIOModeI_InputIN6              GPIO_Mode_IPU
#define GPIOSpeed_InputIN6              GPIO_Speed_2MHz     
#define GPIOxPort_InputIN6              GPIOD                
#define GPIOxBitx_InputIN6              GPIO_Pin_13 

#define RCCPeriph_InputIN7              RCC_APB2Periph_GPIOD 
#define GPIOModeI_InputIN7              GPIO_Mode_IPU
#define GPIOSpeed_InputIN7              GPIO_Speed_2MHz     
#define GPIOxPort_InputIN7              GPIOD                
#define GPIOxBitx_InputIN7              GPIO_Pin_14 

#define RCCPeriph_InputIN8              RCC_APB2Periph_GPIOE 
#define GPIOModeI_InputIN8              GPIO_Mode_IPU
#define GPIOSpeed_InputIN8              GPIO_Speed_2MHz     
#define GPIOxPort_InputIN8              GPIOE                
#define GPIOxBitx_InputIN8              GPIO_Pin_5 

#define RCCPeriph_InputEMSTOP           RCC_APB2Periph_GPIOD
#define GPIOModeI_InputEMSTOP           GPIO_Mode_IPU
#define GPIOSpeed_InputEMSTOP           GPIO_Speed_2MHz
#define GPIOxPort_InputEMSTOP           GPIOD
#define GPIOxBitx_InputEMSTOP           GPIO_Pin_15


typedef struct
{
  uint32_t              RCC_APB2Periph;
  GPIOMode_TypeDef      GPIO_Mode;
  GPIOSpeed_TypeDef     GPIO_Speed;
  GPIO_TypeDef*         GPIOx;
  uint16_t              GPIO_Pin;
} DstInputsCfg_TypeDef;


/***********************************************************/
/* OS DstInputs Flags Table */
/* Port order is same with "DstInputsOrd" */
DSTIN_CFG_EXT const OS_FLAGS OSDSTINFlagsRequestTable[DstInputsOrd_TOTNum];
DSTIN_CFG_EXT const OS_FLAGS OSDSTINFlagsTimingTable[DstInputsOrd_TOTNum];

/* Input port configuration */
/* Port order is same with "DstInputsOrd" */
DSTIN_CFG_EXT const DstInputsCfg_TypeDef DstInputsCfgTable[DstInputsOrd_TOTNum];


/* DstInputs Alarm Type */
#define DstInputsAlarmTypeOrd_TOTNum     10
DSTIN_CFG_EXT const uint16_t DstInputsAlarmTypeListTab[DstInputsAlarmTypeOrd_TOTNum];


/* DstInputs Action Type */
#ifdef ProductMainAvailableOpt
#define DstInputsActionTypeOrd_TOTNum    12
#else
#define DstInputsActionTypeOrd_TOTNum    10
#endif
DSTIN_CFG_EXT const uint16_t DstInputsActionTypeListTab[DstInputsActionTypeOrd_TOTNum];
/* DstInputs Action Workload */
typedef  void (*DstInputsActionHandlingType)(uint8_t ActionSta);
DSTIN_CFG_EXT const DstInputsActionHandlingType DstInputsActionHandlingTbl[DstInputsActionTypeOrd_TOTNum];




/* Pcfg Buffer Order */
#define DstInSta_Open                               DigitalInputCodes_Open
#define DstInSta_Close                              (!DstInSta_Open) 

#define DstInputCfgBFOrd_Type                      (Adr_DigitalInput1Type  -Adr_DigitalInput1Type)
#define DstInputCfgBFOrd_Active                    (Adr_DigitalInput1Active-Adr_DigitalInput1Type)
#define DstInputCfgBFOrd_Action                    (Adr_DigitalInput1Action-Adr_DigitalInput1Type)
#define DstInputCfgBFOrd_Period                    (Adr_DigitalInput1Period-Adr_DigitalInput1Type)
#define DstInputCfgBFOrd_Delay                     (Adr_DigitalInput1Delay -Adr_DigitalInput1Type)
#define DstInputCfgBFNum                           (DstInputCfgBFOrd_Delay+1)

/* Special Fixed Input Define */
#define DstInputFixedCfgOrd_HighTempShutdown      0
#define DstInputFixedCfgOrd_LowOilShutdown        1
#define DstInputFixedCfgOrd_EMSTOP                2
#define DstInputFixedCfgOrd_GensClosed            3
#define DstInputFixedCfgOrd_MainsClosed           4
#define DstInputFixedCfgOrd_AuxiliaryWarning      5
#define DstInputFixedCfgOrd_AuxiliaryShutdown     6
#define DstInputFixedCfgOrd_FuelLevelWarning      7
#define DstInputFixedCfgOrd_FuelLevelShutdown     8
#define DstInputFixedCfgOrd_CoolLevelWarning      9
#define DstInputFixedCfgOrd_CoolLevelShutdown     10
#define DstInputFixedCfgOrd_TOTNum                11

#define DstInputFixedCfgItem_Action               0
#define DstInputFixedCfgItem_Period               1
#define DstInputFixedCfgItem_Delay                2
#define DstInputFixedCfgItem_TOTNum               3

DSTIN_CFG_EXT const uint16_t DstInputFixedCfgTypeTbl[DstInputFixedCfgOrd_TOTNum];
DSTIN_CFG_EXT const uint16_t DstInputFixedCfgParamTbl[DstInputFixedCfgOrd_TOTNum][DstInputFixedCfgItem_TOTNum];


#define DstInputAuxHighTemp_Action                 PcfgAlarmOpt_Shutdown
#define DstInputAuxHighTemp_Period                 PcfgActivePeriod_FromSafetyOn
#define DstInputAuxHighTemp_Delay                  50

#define DstInputAuxLowOP_Action                    PcfgAlarmOpt_Shutdown
#define DstInputAuxLowOP_Period                    PcfgActivePeriod_FromSafetyOn
#define DstInputAuxLowOP_Delay                     30

#define DstInputEMSTOP_Action                      PcfgAlarmOpt_Shutdown
#define DstInputEMSTOP_Period                      PcfgActivePeriod_FromAlways
#define DstInputEMSTOP_Delay                       8

#define DstInputGenClose_Action                    PcfgAlarmOpt_None
#define DstInputGenClose_Period                    PcfgActivePeriod_FromNever
#define DstInputGenClose_Delay                     5

#define DstInputMainClose_Action                   PcfgAlarmOpt_None
#define DstInputMainClose_Period                   PcfgActivePeriod_FromNever
#define DstInputMainClose_Delay                    5

#define DstInputAuxiliaryWarning_Action            PcfgAlarmOpt_Warn
#define DstInputAuxiliaryWarning_Period            PcfgActivePeriod_FromAlways
#define DstInputAuxiliaryWarning_Delay             20

#define DstInputAuxiliaryShutdown_Action           PcfgAlarmOpt_Shutdown
#define DstInputAuxiliaryShutdown_Period           PcfgActivePeriod_FromAlways
#define DstInputAuxiliaryShutdown_Delay            20

#define DstInputFuelLevelWarning_Action            PcfgAlarmOpt_Warn
#define DstInputFuelLevelWarning_Period            PcfgActivePeriod_FromAlways
#define DstInputFuelLevelWarning_Delay             150

#define DstInputFuelLevelShutdown_Action           PcfgAlarmOpt_Shutdown
#define DstInputFuelLevelShutdown_Period           PcfgActivePeriod_FromAlways
#define DstInputFuelLevelShutdown_Delay            150

#define DstInputCoolLevelWarning_Action            PcfgAlarmOpt_Warn
#define DstInputCoolLevelWarning_Period            PcfgActivePeriod_FromAlways
#define DstInputCoolLevelWarning_Delay             150

#define DstInputCoolLevelShutdown_Action           PcfgAlarmOpt_Shutdown
#define DstInputCoolLevelShutdown_Period           PcfgActivePeriod_FromSafetyOn
#define DstInputCoolLevelShutdown_Delay            150

#define DstInputStatus_Delay                       20

#ifdef __cplusplus
}
#endif


#endif   /*  __DSTIN_CFG_H__  */

/******************* (C) COPYRIGHT 2010 Feirui *****END OF FILE****/